using System;

namespace UIFramework
{
    public class Finally : IDisposable
    {
        private Action onDispose;
        private bool disposed;

        public Finally(Action onCreate, Action onDispose)
        {
            this.onDispose = onDispose;
            onCreate?.Invoke();
        }

        public void Dispose()
        {
            if (disposed) return;
            disposed = true;
            onDispose?.Invoke();
        }
    }

}
